<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let arr = new Array(1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4);
        /* 数组去重 */
        Array.prototype.norepeat = function(){
            /* 定义一个新的数组 */
            let newArr = []
            /* 利用对象key值,可以去重,对象的key值就是唯一的 */
            let obj = {}
            /* 将this里面所有的内容都往obj里面扔,value不需要管 */
            for(let i = 0 ; i < this.length ; i++){
                let attr = this[i]
                // console.log(attr);
                obj[attr] = "随便";
            }
            // console.log(obj);|
            for(let key in obj){
                newArr.push(+key)
            }
            return newArr;
        }
        let result = arr.norepeat();
        console.log(result);
    </script>
</body>

</html>